package com.tannm.doan.taskmanager.database;

public class DataRowNote extends DataRow {
	// Table field indexes for field select speedup
	public static class Fid {
		public static final int ID = 0;
		public static final int SUBJECT = 1;
	};

	// Table definition
	private final DataField[] tableDef = {
			new DataField(Fid.ID, "_ID", DataField.Type.INT, true, true),
			new DataField(Fid.SUBJECT, "Subject", DataField.Type.TEXT, true,
					false), };

	// fields
	private String sSubject = "";

	// methods
	public DataRowNote(Database userdb) {
		super(userdb);
		setTableDefinition(tableDef);
	}

	// setters
	public void setSubject(String value) {
		sSubject = new String(value.trim());
	}

	// getters
	public String getSubject() {
		return sSubject;
	}

	// methods
	@Override
	public String toString() {
		String s = "";
		s += sSubject + "\n";
		return s;
	}

	@Override
	public boolean validate() {
		if (sSubject.length() > 0) {
			return true;
		}
		return false;
	}

	@Override
	public void setValuesForDataRow() {
		clearContentValues();

		value(Fid.SUBJECT).set(getSubject());
	}

	@Override
	public void getValuesFromDataRow() {
		setSubject(value(Fid.SUBJECT).asString());
	}

	@Override
	public String getTableName() {
		return Database.sTableNameNotes;
	}

}
